/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package view.ihm;

import mod.dao.tables;
import java.awt.BorderLayout;
import java.sql.ResultSet;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;

/**
 *
 * @author willy
 */
public class Tables extends JPanel{

    // constructeur
    public Tables()
    {
        tables tabledao=new tables();
        ResultSet r=tabledao.Liste();

        int taille=0;
        try{
            r.last();
            taille=r.getRow();
            System.out.println(taille);
            r.beforeFirst();
        }catch(Exception ex) {}

        Object[][] data=new Object[taille][5];
        try {
            int i=0;
            while (r.next())
            {
                data[i][0]=r.getInt("id");
                data[i][1]=r.getString("nom");
                data[i][2]=r.getInt("blind");
                data[i][3]=r.getInt("min");
                data[i][4]=r.getInt("max");
                i++;
                
            }
        }catch(Exception e)
        {
            
        }

        //Les titres des colonnes
		String  title[] = {"Id", "Nom", "Blind", "Min", "Max"};
		JTable tableau = new JTable(data, title);
        add(new JScrollPane(tableau));
    }
    // main
    public static void main(String[] args)
    {
        JFrame Fen=new JFrame("Test");
        Fen.setLayout(new BorderLayout());
        Fen.setSize(700,300);
        Fen.add(new Tables());
        Fen.setVisible(true);
    }

}
